package cn.itsource._04_direct;

import cn.itsource.ConnectionUtil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

//发送消息
public class Send {
    //交换机名称
    public static final String NAME_EXCHANGE_DIRECT = "name_exchange_direct";

    public static void main(String[] args) throws Exception {
        //建立连接对象
        Connection connection = ConnectionUtil.getConnection();
        //建立通道
        Channel channel = connection.createChannel();
        //声明定向交换机
        channel.exchangeDeclare(NAME_EXCHANGE_DIRECT, BuiltinExchangeType.DIRECT);
        //准备消息
        String message = "direct message...";
        //发送消息，指定delete队列
        channel.basicPublish(NAME_EXCHANGE_DIRECT,"update",null,message.getBytes());
        System.out.println("消息发送完毕"+message);

    }




}
